package com.example.demo.controller;

import com.example.demo.base.WebResult;
import com.example.demo.service.DemoService;
import com.example.demo.vo.DemoVO;
import com.example.demo.base.ReqParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class DemoController {

    @Autowired
    private DemoService demoService;

    @RequestMapping(value = "/aop/test1/{companyId}", method = RequestMethod.POST)
    public void test1(@PathVariable String companyId, @RequestParam(name = "param2") String param2) {
        demoService.updateTest1(companyId, param2);
    }

    @RequestMapping(value = "/aop/test2", method = RequestMethod.POST)
    public void test2(@RequestBody Map paramMap, @RequestParam(name = "param2") String param2) {
        demoService.updateTest2(paramMap, param2);
    }

    @RequestMapping(value = "/aop/test3", method = RequestMethod.POST)
    public void test3(@RequestBody DemoVO demoVO) {
        demoService.saveTest3(demoVO);
    }

    @RequestMapping(value = "/aop/test4", method = RequestMethod.POST)
    public WebResult test4(@RequestBody ReqParam<DemoVO> reqParamVO) {
        demoService.saveTest3(reqParamVO.getData());
        //为了演示返回结果的日志打印效果，此处把入参当成返回结果。
        return WebResult.ok(reqParamVO.getData());
    }

}
